# -*- encoding: utf-8 -*-

class Store (object):

    """ Classe définissant une instruction STORE Val(Ra) Rb. """

    def __init__ (self, val, ra, rb, mem):
        self.__ra = ra 
        self.__rb = rb
        self.__val = val
        self.__mem = mem

    def do (self):
        self.__mem.setRamAt(
            addr = (self.__mem.getRegister(self.__ra) + self.__val) % 256,
            newVal = self.__mem.getRegister(self.__rb)
            )

    def __str__ (self):
        return "store {0:d}(r{1:d}) r{2:d}".format(self.__val, self.__ra, self.__rb) 

    def __unicode__ (self):
        return self.__str__ () 
